This application relates to industrial controllers and more particularly to a method of recreating the ladder logic source code used in programming such controllers, from the user compiled program run by such controllers, without the use of "tokenized" decompiling instructions.
Industrial controllers such as those described in U.S. Pat. Nos. 3,810,118; 3,942,158, 4,165,534 and 4,442,504 are typically connected to industrial equipment such as assembly lines or machine tools to operate such equipment in accordance with a stored program. In industrial controllers, such as those disclosed in the above cited patents, the stored program includes instructions which, when executed, examine the condition of selected sensing devices on the controlled equipment or energize or de-energize selected operating devices on the controlled equipment contingent on the status of one or more of the examined sensing devices. Inputs to the controller may be discrete binary signals such as from switches which may detect limits of motion, temperature, time, or other continuously variable quantities, or the inputs may be analog measures of the quantities themselves which are generally then converted to digital binary form for processing.
Likewise, the outputs of the controller may be either binary outputs as implemented by mechanical or solid-state relays, or analog outputs produced by means of a digital to analog converter.
Industrial controllers are typically programmed in a ladder logic language in which instructions are represented by the elements of a relay ladder diagram. The ladder logic language is in a form readily understood by control engineers and has become largely standardized in the industry. Program panels such as those disclosed in U.S. Pat. Nos. 3,798,612, 3,813,649 and 4,070,702 have been developed to assist the user in developing and editing ladder logic programs.
During execution, ladder logic programs are converted on an instruction-by-instruction basis to machine code instructions that may be executed directly by the computer hardware that forms the basis of the controller. This conversion is performed by an interpreter program which analyzes each ladder rung or subpart of a rung and presents the computer with a machine code subroutine defined by that part of the ladder. Accordingly, an industrial controller programmed in the ladder logic language may be executed on a machine designed around conventional computer architecture.
There are two drawbacks to interpreter base controllers. First, the interpreter program must be stored in the controller memory along with the ladder logic program during the operation of the controller. This limits the memory available for the ladder logic program. Second, the continuous interpretation of the ladder logic program during the controller operation slows the controller operation. The resultant speed limitations reduce the length of the ladder logic program that may be executed.
One well known way of speeding up program execution and improving memory usage is to compile the ladder logic program into machine code and to store only the machine code in the controller during operation. A duplicate of the original ladder logic program is stored separately, for example, on floppy disk or magnetic tape, to be used if later changes are to be made in the program. However, storing copies of the original ladder logic program may not be convenient in an industrial environment where they must be stored separately from the controller to protect them from contamination or erasure.
An alternative approach is to "decompile" the stored machine code back into the ladder logic program that may be understood and edited by the programer. The decompiling and compiling program may be stored in a separate programming terminal to avoid taking up controller memory space. While this approach is extremely attractive from the point of view of operator convenience, under many current compilation techniques it may be impossible to reconstruct the ladder logic program from the machine code. This occurs because many compilation techniques effectively discard information necessary to uniquely identify which of the many ladder logic structures generated the particular logic sequence embodied in the machine code.
Accordingly such compilers may include additional source language "tokens" in the compiled machine code, not executed by the controller, but serving only to aid in decompiling the machine code to ladder logic instructions. An example of such a technique is described in co-pending U.S. Pat. No. application 07/161,484 filed Feb. 29, 1988.